package cn.com.generaldata.os.vo;

import java.util.List;

public class ResultVO<T> {

	public static final int DEFAULT_PAGE_SIZE = 20;

	private List<T> operationResult;
	private int pageSize;
	private int pageNumber;
	private int totalCount;

	public ResultVO() {
	}

	public ResultVO(List<T> operationResult, int pageSize, int pageNumber, int totalCount) {
		super();
		this.operationResult = operationResult;
		this.pageSize = pageSize;
		this.pageNumber = pageNumber;
		this.totalCount = totalCount;
	}

	public void setOperationResult(List<T> operationResult) {
		if (operationResult == null) {
			throw new IllegalArgumentException("'operationResult' must be not null");
		} else {
			this.operationResult = operationResult;
			return;
		}
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNumber() {
		return pageNumber;
	}

	public void setPageNumber(int pageNumber) {
		this.pageNumber = pageNumber;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public List<T> getOperationResult() {
		return operationResult;
	}

	public int getTotalPages() {
		if (totalCount % pageSize == 0) {
			return totalCount / pageSize;
		}
		return (totalCount / pageSize) + 1;
	}

}
